package com.atguigu.gmall.product.service.impl;

import com.atguigu.gmall.model.product.BaseTrademark;
import com.atguigu.gmall.product.mapper.BaseTrademarkMapper;
import com.atguigu.gmall.product.service.BaseTrademarkService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/***
 * 商标品牌表service层实现类
 */
@Service
public class BaseTrademarkServiceImpl implements BaseTrademarkService {

    @Autowired
    private BaseTrademarkMapper baseTrademarkMapper;

    /**
     * 分页查询数据
     *
     * @param pageNum
     * @param size
     * @return
     */
    @Override
    public IPage<BaseTrademark> page(Long pageNum, Long size) {
        //1 分页对象
        Page<BaseTrademark> page = new Page<>(pageNum, size);

        //2 分页查询
        IPage<BaseTrademark> baseTrademarkIPage = baseTrademarkMapper.selectPage(page, null);

        //3 返回数据
        return baseTrademarkIPage;
    }

    /**
     * 查询所有数据
     *
     * @return
     */
    @Override
    public List<BaseTrademark> list() {
        return baseTrademarkMapper.selectList(null);
    }

    /**
     * 根据品牌id查询品牌信息
     *
     * @param tmId
     * @return
     */
    @Override
    public BaseTrademark getById(Long tmId) {
        return baseTrademarkMapper.selectById(tmId);
    }
}
